import request from '@/utils/request'

interface ParamsPage {
	pageSize?: number
	pageCode?: number
	searchValue?: string
}

export function fetchList(params?: ParamsPage) {
	return request({
		url: '/api/list',
		method: 'get',
		params
	})
}

interface DataDelete {
	id: string | string[]
}
export function deleteList(data: DataDelete) {
	return request({
		url: '/api/delete',
		method: 'post',
		data
	})
}

interface User {
	user: string
	pwd: string
}

export function login (data: User) {
	return request({
		url: '/api/login',
		method: 'post',
		data
	})
}

interface Permission {
	token: string
}

export function getPermission(data: Permission) {
	return request({
		url: '/api/user/permission',
		method: 'post',
		data
	})
}

export function addListItem (data: any) {
	return request({
		url: '/api/list/add',
		method: 'post',
		data
	})
}